package com.design.cjm.test;

/**
 * 双重锁校验 懒汉式 线程安全
 *
 * @Author: Jie Ming Chen
 * @Date: 2019-02-21
 * @Version 1.0
 */
public class Singleton {

    private volatile static Singleton singleton;

    private Singleton() {
    }

    public static Singleton getInstance() {
        if (singleton == null) {
            synchronized (Singleton.class) {
                if (singleton == null) {
                    return new Singleton();
                }
            }
        }
        return singleton;
    }
}
